//
//  ZYCAttendanceEvaluateDetailHeaderView.m
//  ZDSC
//
//  Created by ZDTX on 2021/8/3.
//

#import "ZYCAttendanceEvaluateDetailHeaderView.h"
#import "ZYCTeachingEvaluatedDetailModel.h"
@interface ZYCAttendanceEvaluateDetailHeaderView ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *scoreLabel;
@end
@implementation ZYCAttendanceEvaluateDetailHeaderView

- (void)setModel:(ZYCTeachingEvaluatedDetailModel *)model{
    _model = model;
    _nameLabel.text = [NSString stringWithFormat:@"评价人:%@",model.userName];
    _scoreLabel.text = [NSString stringWithFormat:@"总分:%.1f",[model.finalScore floatValue]];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = HEX_RGB(@"FFFFFF");
        [self addSubview:self.bgView];
        [self addSubview:self.nameLabel];
        [self addSubview:self.scoreLabel];
        
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(self);
            make.height.mas_equalTo(15.0f);
        }];
        
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(15.0f);
            make.top.equalTo(self.bgView.mas_bottom).offset(16.0f);
        }];
        
        [self.scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-15.0f);
            make.centerY.equalTo(self.nameLabel);
        }];
    }
    return self;
}

- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = HEX_RGB(@"#F9F9F9");
    }
    return _bgView;
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [UILabel LabelWithFont:kSystemBoldFont(18.0f) titleColor:HEX_RGB(@"#2B302D") textAlignment:ZZTextAlignmentLeft];
    }
    return _nameLabel;
}

- (UILabel *)scoreLabel {
    if (!_scoreLabel) {
        _scoreLabel = [UILabel LabelWithFont:kSystemBoldFont(18.0f) titleColor:HEX_RGB(@"#E93C06") textAlignment:ZZTextAlignmentRight];
    }
    return _scoreLabel;
}

@end
